package com.Spring.bean.lifecycle;

import org.springframework.context.ApplicationContext;
import org.springframework.context.support.AbstractApplicationContext;
import org.springframework.context.support.ClassPathXmlApplicationContext;

public class LifecycleTest {

    public static void main(String[] args) {

        // 加载 lifecycle.xml 配置文件
        ApplicationContext context = new ClassPathXmlApplicationContext("lifecycle.xml");

        // 获取 bean 实例 lifecycle
        Lifecycle lifecycle = (Lifecycle) context.getBean("lifecycle");
        lifecycle.print();

        // 关闭 spring 容器
        ((AbstractApplicationContext)context).close();

    }

}
